﻿using System.Configuration;
using System.IO;

namespace PivotIO.XML
{
    public class Utils
    {
        /// <summary>
        /// Return the root directory for all the data for this app.
        /// </summary>
        /// <returns></returns>
        public static DirectoryInfo GetROOTDataDirectory()
        {
            var di = new DirectoryInfo(ConfigurationManager.AppSettings["ROOTXMLDirectory"]);
            if (!di.Exists)
                di.Create();
            return di;
        }

        /// <summary>
        /// Return the directory that is watched for rendering signals between the web service and the
        /// rendering backend.
        /// </summary>
        /// <returns></returns>
        public static DirectoryInfo GetRenderWatchDirectory()
        {
            var di = new DirectoryInfo(Path.Combine(GetROOTDataDirectory().FullName, "RenderUpdatesPending"));
            if (!di.Exists)
                di.Create();
            return di;
        }

        /// <summary>
        /// Return the directory that contains all the web renderings.
        /// </summary>
        /// <returns></returns>
        public static DirectoryInfo GetWebDataDirectory()
        {
            var di = new DirectoryInfo(ConfigurationManager.AppSettings["CXMLRenderDirectory"]);
            return di;
        }
    }
}